<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			html,body,.mui-content{
				background-color: white;
			}
			
			.mui-bar {
				background-color: #3B559F;
				width: 100%;
				color: #FFFFFF
			}
			
			.mui-bar a,.mui-bar h1 {
				color: #FFFFFF;
			}
			
			.mui-content input{
				width: 97%;
				margin-left: 3%;
				border: hidden;
				margin-bottom: 0;
				padding: 3px 0!important;
				font-size: 90%;
			}
			
			.ts-div {
				margin-top: 5%;
				text-align: center;
				padding: 0;
				padding-bottom: 20px;
			}
			
			.ts-text {
				color: #ABABAB;
				font-size: 90%;
			}
			
			.input-div {
				width: 90%;
				margin-left: 5%;
				border-bottom: 1px solid #E5E5E5;
			}
			
			.mui-btn{
				margin-top: 20px;
				width: 90%;
				margin-left: 5%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">注册</h1>
		</header>

		<div id="" class="mui-content">
			<div class="ts-div">
				<h4>请输入基本信息</h4>
				<span class="ts-text">登陆和被添加好友时，需要用到账号</span>
			</div>
			<div id="" class="input-div"><input type="text" id="accnumber" placeholder="账号(最少6个字母和数字)" onKeyUp="value=value.replace(/[\W]/g,'')" oninput="if(value.length>12)value=value.slice(0,12)" /></div>
			<div id="" class="input-div"><input type="text" id="nickname" class="input4" placeholder="昵称"/></div>
			<div id="" class="input-div"><input type="password" id="password" placeholder="密码"/></div>
			<div id="" class="input-div input-div1"><input type="password" id="newpassword" width="66%" placeholder="确定密码"/></div>
			<button type="button" id="xia" class="mui-btn mui-btn-blue login-btn">下一步</button>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/immersed.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			mui.plusReady(function() {
				starbar();
				
				var viewwidth = document.body.clientWidth;
				var pngg = document.getElementsByClassName('input-div');
				pngg[0].style.padding = "-webkit-calc(" + viewwidth * 0.03 + "px) 0";
				pngg[1].style.padding = "-webkit-calc(" + viewwidth * 0.03 + "px) 0";
				pngg[2].style.padding = "-webkit-calc(" + viewwidth * 0.03 + "px) 0";
				pngg[3].style.padding = "-webkit-calc(" + viewwidth * 0.03 + "px) 0";
				
				var setData = plus.webview.currentWebview();
				document.getElementById('xia').addEventListener('tap', function() {
					var reg = /^[a-zA-Z]*$/;
					var IyCard = document.getElementById('accnumber').value;
					var IyNickName = document.getElementById('nickname').value;
					var IyPassword = document.getElementById('password').value;
					var TynrePassword = document.getElementById('newpassword').value;
					if(IyCard == "" || IyNickName == "" || IyPassword == "" || TynrePassword == "") {
						mui.toast("所有输入框不能为空！")
					} else {
						if(IyCard && !isNaN(IyCard)) {
							mui.toast("账号至少要包含一个字母")
						} else if(IyCard && reg.test(IyCard)) {
							mui.toast("账号至少要包含一个数字")
						} else if(IyCard.length < 6) {
							mui.toast('账号不足六位');
						} else {
							if(IyPassword != TynrePassword) {
								mui.toast("密码设置不一致")
							} else {
								mui.ajax('https://www.lunyuwang.com/userController/registJBen', {
									data: {
										lyuser_Card: IyCard,
										lyuser_NickName: IyNickName,
										lyuser_Password: IyPassword,
										lyuser_Tel: setData.shoujihao
									},
									dataType: 'json', //服务器返回json格式数据
									type: 'get', //HTTP请求类型
									timeout: 1000, //超时时间设置为10秒；
									headers: {
										'Content-Type': 'application/x-www-form-urlencoded'
									},
									success: function(data) {
										if(data.state == 1) {
											mui.alert("账号和昵称均已存在！")
										} else if(data.state == 0) {
											mui.toast("网络异常，请重试")
										} else {
											mui.openWindow({
												url: "register33.html",
												id: "register33.html",
												extras: {
													lyuser_Card: IyCard
												},
											})
										}
									},
									error: function(xhr, type, errorThrown) {
										//异常处理；
										mui.toast('网络异常');
									}
								})
							}
						}
					}

				})
			})
		</script>
	</body>

</html>